export function deepCopyAndSort(obj: any): any {
  if (Array.isArray(obj)) {
    return obj.map(deepCopyAndSort).sort((a, b) => {
      const aStr = JSON.stringify(a)
      const bStr = JSON.stringify(b)
      return aStr.localeCompare(bStr)
    })
  } else if (obj !== null && typeof obj === 'object') {
    const sortedObj: any = {}
    const keys = Object.keys(obj).sort()
    for (const key of keys) {
      sortedObj[key] = deepCopyAndSort(obj[key])
    }
    return sortedObj
  } else {
    return obj
  }
}

export function deepCopyAndSortCallback(data1: any, data2: any): any {
  data1 = deepCopyAndSort(data1)
  data2 = deepCopyAndSort(data2)

  return { data1, data2 }
}
